package games.gong.durid.controller;

import com.eternal.peaceworld.service.AesEncryptorService;
import games.gong.durid.common.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;

@RestController
@RequestMapping("/api/public")
public class PublicController {
    private static final Logger logger = LoggerFactory.getLogger(PublicController.class);

    @Autowired
    private AesEncryptorService aesEncryptorService;

    @GetMapping("/info")
    public R<Map<String, Object>> getPublicInfo() {
        Map<String, Object> info = new HashMap<>();
        String encrypted = aesEncryptorService.encrypt("abc");
        logger.debug("加密操作成功，加密结果: {}", encrypted);

        info.put("appName", "Spring Boot Druid Application");
        info.put("timestamp", LocalDateTime.now());
        info.put("currentUser", "anonymous");
        info.put("hasUserRole", false);
        info.put("hasAdminRole", false);
        
        return R.success("获取公共信息成功", info);
    }
    
    @GetMapping("/health")
    public R<String> healthCheck() {
        return R.success("服务运行正常", "OK");
    }
}